<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org/">
<head th:replace="page/index::head">

</head>
<body class="layui-layout-body layuimini-all">
<div class="layui-layout layui-layout-admin">

    <div class="layui-header header" th:replace="page/index::nav">
    </div>

    <div class="layui-side layui-bg-black" th:replace="page/index::left">
    </div>

    <div class="layui-body">
        <div class="layuimini-content-page">
            <!--初始化中间内容-->
            <div class="layuimini-container layui-anim layui-anim-upbit ">
                <div class="layuimini-main content">
                   <table class="layui-table">
                       <thead>
                       <tr>
                           <td>编号</td>
                           <td>标题</td>
                           <td>更新时间</td>
                           <td>发布者</td>
                           <td>操作</td>
                       </tr>
                       </thead>
                       <tbody>
                       <tr th:each="notice,noticeStat:${noticeList}">
                           <td th:text="${noticeStat.index+1}"></td>
                           <td th:text="${notice.noticeTitle}"></td>
                           <td th:text="${#dates.format(notice.updateTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                           <td th:text="${notice.updateBy}"></td>
                           <td th:if="${session.user.role==1}">
                               <div class="layui-table-cell laytable-cell-1-0-10">
                                   <a class="layui-btn layui-btn-xs data-count-edit"
                                     th:href="@{/notice/edit(noticeId=${notice.noticeId})}" lay-event="edit">编辑</a>
                                   <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete"
                                      th:href="@{/notice/delete(noticeId=${notice.noticeId})}"
                                      lay-event="delete">删除</a>
                               </div>
                           </td>

                           <td th:if="${session.user.role==0}">
                               <div class="layui-table-cell laytable-cell-1-0-10">

                                   <a class="layui-btn layui-btn-xs data-count-view look"
                                     th:href="@{/notice/findNotice(noticeId=${notice.noticeId})}"
                                      lay-event="look">查看
                                   </a>

                               </div>
                           </td>
                       </tr>
                       </tbody>
                   </table>
                    <p class="errorMag"
                       style="width: 318.4px;height: 30px;padding-top: 40px;padding-left:350px;
                       text-align: center;color: crimson" th:text="${errorMsg}"></p>
                </div>
            </div>
        </div>
    </div>

</div>
<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" src="../../static/lib/jquery-3.4.1/jquery-3.4.1.min.js"
        charset="utf-8"></script>
<script th:src="@{/lib/layui-v2.5.5/layui.js}" src="../../static/lib/layui-v2.5.5/layui.js?v=1.0.4"
        charset="utf-8"></script>
<script th:src="@{/lib/layui-v2.5.5/layui.all.js}" src="../../static/lib/layui-v2.5.5/layui.js?v=1.0.4"
        charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" src="../../static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script type="text/javascript">

    layui.use(['layer', 'layuimini'], function () {
        $('.login-out').on("click", function () {
            layer.msg('正在退出登录', function () {
                window.location = '/user/logout';
            });
        });
        /* layuimini.listen();*/
    });
    /*查看最新时间发布的公告*/
    $(".view_notice").click(function () {

        $.get("/notice/getFirstNotice",function (result) {
            result = result.data;
            $(".publish h1").html(result.noticeTitle);
            $(".publish p").html(result.noticeContent);
            layer.open({
                type: 1
                , title: '公告' //标题栏
                , closeBtn: false
                , area: '300px;'
                , shade: 0.8
                , id: 'notice-publish' //设定一个id，防止重复弹出
                , resize: false
                , btn: ['我知道了']
                , btnAlign: 'c'
                , moveType: 1 //拖拽模式，0或者1
                , content:$(".publish")

            });
        });
        /*  */
    });

    /*头像上传*/
    $(".uploadAvatar").click(function () {
        layer.open({
            type: 1
            , title: '上传头像' //不显示标题栏
            , closeBtn: 2
            , area: '300px;'
            , id: 'upload-avatar' //设定一个id，防止重复弹出
            , resize: false
            , btnAlign: 'c'
            , moveType: 1 //拖拽模式，0或者1
            , content: $(".magt3")

        });
        layui.use('upload', function () {
            var upload = layui.upload;
            var uploadInst = upload.render({
                elem: '#test1'
                ,auto:true

                , url: '/user/projectPictureUpload'
                , method: 'post'
                , accept: 'images'
                , acceptMime: 'image/*'
                , field: 'projectImg'
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $("#demo1").attr('src',result);
                    })}
                , done: function (res) {
                    //如果上传失败
                    if (res.status == 1) {
                        return layer.msg('上传项目图片失败', {icon: 5});
                    }
                    //上传成功,获得图片地址
                    console.log(res.data);

                    $('.avatar').attr('src', res.data);
                    layer.closeAll();
                    // window.location.reload();
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
        });
    });
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer;

    });
</script>
</body>


<div class="publish" style="padding: 50px; line-height: 22px;
background-color: #393D49; color: #fff; font-weight: 300;">
    <h1></h1><br><br>
    <p>

    </p>
</div>
<!--上传头像框-->
<div class="layui-form layui-form-item magt3">

    <div class="layui-upload">
        <button type="button" class="layui-btn" style="margin-left: 100px;" id="test1">选择图片</button>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="demo1" style="margin-left:80px;width: 140px;height: 115px;">
            <p id="demoText"></p>
        </div>

    </div>

</div>

</html>